package com.hjc.controller;

import com.hjc.entity.ProductType;
import com.hjc.entity.Purchase;
import com.hjc.entity.Result;
import com.hjc.entity.Store;
import com.hjc.page.Page;
import com.hjc.service.ProduceTypeService;
import com.hjc.service.PurchaseService;
import com.hjc.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/productCategory")
public class ProductTypeController {
    @Autowired
    private ProduceTypeService produceTypeService;
    @Autowired
    private StoreService storeService;
    @Autowired
    private PurchaseService purchaseService;


//    http://localhost:3000/api/productCategory/product-category-tree
    @RequestMapping("/product-category-tree")
    public Result findProductCategory() {
        List<ProductType> productTypeTree = produceTypeService.findAllProductType();
        return Result.ok(productTypeTree);
    }

//    http://localhost:3000/api/productCategory/verify-type-code?typeCode
    @RequestMapping("/verify-type-code")
    public Result addProductCategory(String typeCode) {
        return produceTypeService.selectProductTypeByCode(typeCode);
    }

//  http://localhost:3000/api/productCategory/type-add
    @RequestMapping("/type-add")
    public Result addProduceType(@RequestBody ProductType productType) {
        return produceTypeService.addProductType(productType);
    }

//  http://localhost:3000/api/productCategory/type-delete/20
    @RequestMapping("/type-delete/{typeId}")
    public Result removeProductTypeById(@PathVariable Integer typeId) {
        return produceTypeService.removeProductTypeById(typeId);
    }

//    http://localhost:3000/api/productCategory/type-update
    @RequestMapping("/type-update")
    public Result setProductType(@RequestBody ProductType productType) {
        return produceTypeService.setProductType(productType);
    }








}
